package com;


import com.util.DisposeNinePatch;
import com.util.IsDark;
import com.util.ReadColor;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.control.Separator;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class ShowView {
    String themedirindex = "";

    /**
     * 拼接图片
     *
     * @param maindir 图片素材路径
     * @return 完成的预览图组件
     */
    public VBox showFirstView(String[] maindir, InputStream[] statuDir, boolean isDrak) {
        String themedir = maindir[0].substring(0, maindir[0].lastIndexOf("/"));
        String themedirindex = themedir.substring(0, themedir.lastIndexOf("/"));
        //1
        VBox vBox = new VBox();
        try {
            ImageView imageView = new ImageView(new Image(new FileInputStream(maindir[0])));
            imageView.setFitWidth(480);
            imageView.setFitHeight(834);
            ImageView imageView1 = new ImageView(new Image(new FileInputStream(maindir[1])));
            imageView1.setFitWidth(480);
            imageView1.setFitHeight(843);
            ImageView imageView2 = new ImageView(new Image(new FileInputStream(maindir[2])));
            imageView2.setFitWidth(480);
            imageView2.setFitHeight(268);
            ImageView imageView3 = new ImageView(new Image(new FileInputStream(maindir[3])));
            imageView3.setFitWidth(60);
            imageView3.setFitHeight(60);
            ImageView imageView4 = new ImageView(new Image(new FileInputStream(maindir[4])));
            imageView4.setFitWidth(150);
            imageView4.setFitHeight(60);
            ImageView imageView5 = new ImageView(new Image(new FileInputStream(maindir[5])));
            imageView5.setFitWidth(60);
            imageView5.setFitHeight(60);

            StackPane stackPane = new StackPane();
            stackPane.getChildren().addAll(imageView, imageView1);

            VBox statuVBox = new VBox();
//            HBox statuHBox = getStatusBarHBox(statuDir);
            StackPane statusBarStackPane = getStatusBarStackPane(themedirindex, statuDir, true, isDrak);

            //拨号盘
            VBox vBox1 = new VBox();
            vBox1.setPadding(new Insets(470, 0, 0, 24));
            vBox1.getChildren().add(imageView2);

            HBox hBox = new HBox();
//            hBox.setPadding(new Insets(0, 55, 0, 55));
            hBox.setPadding(new Insets(0, 55, 0, 55));
            hBox.setSpacing(50);
            hBox.getChildren().setAll(imageView3, imageView4, imageView5);

            vBox1.getChildren().add(hBox);
///////////
            statuVBox.getChildren().addAll(statusBarStackPane, vBox1);

            stackPane.getChildren().add(statuVBox);

            vBox.getChildren().add(stackPane);

            vBox.setPadding(new Insets(20, 20, 20, 50));

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return vBox;
    }

    public VBox showSecondView(String[] maindir, InputStream[] statuDir, boolean isDrak) {
        String themedir = maindir[0].substring(0, maindir[0].lastIndexOf("/"));
        themedirindex = themedir.substring(0, themedir.lastIndexOf("/"));
        VBox vBox = new VBox();
        try {
            ImageView imageView = new ImageView(new Image(new FileInputStream(maindir[0])));
            imageView.setFitWidth(480);
            imageView.setFitHeight(834);
            //编辑
            //搜索
            ImageView imageView3 = new ImageView(new Image(new FileInputStream(maindir[3])));
            imageView3.setFitWidth(40);
            imageView3.setFitHeight(40);

            StackPane stackPane = new StackPane();
            stackPane.getChildren().add(imageView);

            VBox vBox1 = new VBox();
            //状态栏
            StackPane statuPan = getStatusBarStackPane(themedirindex, statuDir, true, isDrak);
            //中间
            Color color = ReadColor.getColor(new Image("file:" + maindir[1]), 43, 53);

            HBox hBox = new HBox();
            hBox.setSpacing(200);
            Text text = new Text("编辑");
            text.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 25));
            HBox hBox1t = new HBox(text);
            hBox1t.setPadding(new Insets(10,0,0,20));
            String colorv1[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml ", "windowTitleColor");
            text.setFill(Color.web(colorv1[0], (double) Integer.parseInt(colorv1[1], 16)/255));
            Text text1 = new Text("信息");
            HBox hBox1t1 = new HBox(text1);
            hBox1t1.setPadding(new Insets(10,130,0,150));
            text1.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 25));
            String colorv2[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml ", "windowTitleColor");
            text1.setFill(Color.web(colorv2[0], (double) Integer.parseInt(colorv2[1], 16)/255));
            ImageView imageView1 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[1], 150, 150))));
            imageView1.setFitWidth(60);
            imageView1.setFitHeight(60);
            hBox.getChildren().addAll(hBox1t, hBox1t1, imageView1);
            //hBox.setAlignment(Pos.CENTER);
            //hBox.setPadding(new Insets(0, 0, 0, 200));
            hBox.setSpacing(10);
            //搜索
            StackPane stackPane1 = new StackPane();
            //stackPane1.setStyle("-fx-background-color: white");
            stackPane1.setPadding(new Insets(0, 0, 0, 30));
            //stackPane1.setPrefSize(400, 120);
            //处理.9图片

            ImageView imageView2 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[2], 1000, 100))));
            imageView2.setFitWidth(460);
            imageView2.setFitHeight(40);

            ImageView imageView4 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[4], 1100, 200))));
            imageView4.setFitWidth(480);
            imageView4.setFitHeight(50);
            HBox hBox11 = new HBox(imageView4);
            hBox11.setPadding(new Insets(0,0,0,24));


            HBox secHBox = new HBox(imageView2);
            secHBox.setPadding(new Insets(5, 0, 5, 10));
            secHBox.setMaxWidth(480);
//            secHBox.setStyle("-fx-background-color: white");
//            if (isDrak) {
//                secHBox.setStyle("-fx-background-color: black");
//            }
//            if (color.toString().equals(ResName.color[2])) {
//                String s = statuDir[8].substring(0, statuDir[8].lastIndexOf("/"));
//                System.out.println(s);
//                Color color1 = ReadColor.getColor(new Image("file:" + s + "/vivo_upslide_music_play_normal.png"), 20, 15);
//                secHBox.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
//            }

            HBox hBox1 = new HBox();
            hBox.setPadding(new Insets(0, 0, 0, 20));
            Text text2 = new Text("搜索信息");
            text2.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            String colorv3[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml ", "edittext_hint_color");
            text2.setFill(Color.web(colorv3[0], (double) Integer.parseInt(colorv3[1], 16)/255));
            hBox1.getChildren().addAll(imageView3, text2);
            hBox1.setAlignment(Pos.CENTER_LEFT);
            hBox1.setPadding(new Insets(0, 0, 0, 40));
            stackPane1.getChildren().addAll(hBox11,secHBox, hBox1);
            stackPane1.setPadding(new Insets(0, 0, 0, 0));

            //文本
            String one[] = {"10086", "09:58",
                    "尊敬的客户，您好！您本月-国内移动数据总…"};
            String two[] = {"糖糖", "1月12日",
                    "您好，非常感谢您的喜欢~我们会继续努力呢^^…"};
            String three[] = {"10010", "2017年11月28日",
                    "温馨提示：至28日10时27分，您的账户当前可用…"};
            String four[] = {"123456789", "2017年5月22日",
                    "【江苏移动】尊敬的客户，4月积分账单已经送达…"};
            String five[] = {"123456789", "2017年5月22日",
                    "【江苏移动】不换机、不加卡，一招教您拥有另…"};

            Color color1 = null;
            String s = maindir[2].substring(0, maindir[2].lastIndexOf("/"));
            System.out.println(s);
            color1 = ReadColor.getColor(new Image("file:" + s + "/vigour_btn_title_tab_left_center_contact_pressed.9.png"), 30, 60);
            if (color.toString().equals(ResName.color[2])) {
                color1 = Color.GRAY;
            }

            GridPane gridPane = getTextGrid(one, color1);
            GridPane gridPane1 = getTextGrid(two, color1);
            GridPane gridPane2 = getTextGrid(three, color1);
            GridPane gridPane3 = getTextGrid(four, color1);
            GridPane gridPane4 = getTextGrid(five, color1);


            VBox gvbox = new VBox(gridPane, gridPane1, gridPane2, gridPane3, gridPane4);

            vBox1.getChildren().addAll(statuPan, hBox, stackPane1, gvbox);
            stackPane.getChildren().add(vBox1);
            vBox.getChildren().add(stackPane);

            vBox.setPadding(new Insets(20, 20, 20, 50));

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return vBox;
    }

    public VBox getThirdView(String[] maindir, InputStream[] statuDir, boolean isDrak) {
        String themedir = maindir[0].substring(0, maindir[0].lastIndexOf("/"));
        themedirindex = themedir.substring(0, themedir.lastIndexOf("/"));
        VBox vBox = new VBox();
        try {
            //背景图
            ImageView imageView1 = new ImageView(new Image(new FileInputStream(maindir[0])));
            imageView1.setFitWidth(480);
            imageView1.setFitHeight(834);
            //时钟栏
            ImageView imageView2 = new ImageView(new Image(new FileInputStream(maindir[1])));
            imageView2.setFitWidth(460);
            imageView2.setFitHeight(120);
            //头像栏
//            ImageView imageView3 = new ImageView(new Image(new FileInputStream(maindir[2])));
//            imageView3.setFitWidth(460);
//            imageView3.setFitHeight(130);
            //白色编辑图标
            ImageView imageView4 = new ImageView(new Image(new FileInputStream(maindir[3])));
            imageView4.setFitWidth(30);
            imageView4.setFitHeight(30);

            List<ImageView> imageViews = new ArrayList<>();
            List<Text> texts = new ArrayList<>();
            List<VBox> vBoxes = new ArrayList<>();
            //闹钟时钟
            ImageView imageView5 = new ImageView(new Image(new FileInputStream(maindir[4])));
            Text text5 = new Text("闹钟时钟");
            VBox vBox5 = new VBox(imageView5, text5);
            texts.add(text5);
            vBoxes.add(vBox5);
            imageViews.add(imageView5);
            //文件管理
            ImageView imageView6 = new ImageView(new Image(new FileInputStream(maindir[5])));
            Text text6 = new Text("文件管理");
            VBox vBox6 = new VBox(imageView6, text6);
            texts.add(text6);
            vBoxes.add(vBox6);
            imageViews.add(imageView6);
            //相册
            ImageView imageView7 = new ImageView(new Image(new FileInputStream(maindir[6])));
            Text text7 = new Text("相册");
            VBox vBox7 = new VBox(imageView7, text7);
            texts.add(text7);
            vBoxes.add(vBox7);
            imageViews.add(imageView7);
            //i音乐
            ImageView imageView8 = new ImageView(new Image(new FileInputStream(maindir[7])));
            Text text8 = new Text("i音乐");
            VBox vBox8 = new VBox(imageView8, text8);
            texts.add(text8);
            vBoxes.add(vBox8);
            imageViews.add(imageView8);
            //录音机
            ImageView imageView9 = new ImageView(new Image(new FileInputStream(maindir[8])));
            Text text9 = new Text("录音机");
            VBox vBox9 = new VBox(imageView9, text9);
            texts.add(text9);
            vBoxes.add(vBox9);
            imageViews.add(imageView9);
            //日历
            ImageView imageView10 = new ImageView(new Image(new FileInputStream(maindir[9])));
            Text text10 = new Text("日历");
            VBox vBox10 = new VBox(imageView10, text10);
            texts.add(text10);
            vBoxes.add(vBox10);
            imageViews.add(imageView10);
            //视频
            ImageView imageView11 = new ImageView(new Image(new FileInputStream(maindir[10])));
            Text text11 = new Text("视频");
            VBox vBox11 = new VBox(imageView11, text11);
            texts.add(text11);
            vBoxes.add(vBox11);
            imageViews.add(imageView11);
            //i主题
            ImageView imageView12 = new ImageView(new Image(new FileInputStream(maindir[11])));
            Text text12 = new Text("i主题");
            VBox vBox12 = new VBox(imageView12, text12);
            texts.add(text12);
            vBoxes.add(vBox12);
            imageViews.add(imageView12);
            //电话
            ImageView imageView13 = new ImageView(new Image(new FileInputStream(maindir[12])));
            Text text13 = new Text("电话");
            VBox vBox13 = new VBox(imageView13, text13);
            texts.add(text13);
            vBoxes.add(vBox13);
            imageViews.add(imageView13);
            //联系人
            ImageView imageView14 = new ImageView(new Image(new FileInputStream(maindir[13])));
            Text text14 = new Text("联系人");
            VBox vBox14 = new VBox(imageView14, text14);
            texts.add(text14);
            vBoxes.add(vBox14);
            imageViews.add(imageView14);
            //信息
            ImageView imageView15 = new ImageView(new Image(new FileInputStream(maindir[14])));
            Text text15 = new Text("信息");
            VBox vBox15 = new VBox(imageView15, text15);
            texts.add(text15);
            vBoxes.add(vBox15);
            imageViews.add(imageView15);
            //相机
            ImageView imageView16 = new ImageView(new Image(new FileInputStream(maindir[15])));
            Text text16 = new Text("相机");
            VBox vBox16 = new VBox(imageView16, text16);
            texts.add(text16);
            vBoxes.add(vBox16);
            imageViews.add(imageView16);

            for (ImageView i : imageViews) {
                i.setFitWidth(80);
                i.setFitHeight(80);
            }

            Color color1 = ReadColor.getColor(new Image("file:" + maindir[20]), 80, 80);

            for (Text t : texts) {
                t.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 16));
                String s[] = new MainListenController().getXmlvalue(themedirindex + "/com.bbk.launcher2\\theme_values.xml", "icon_title_color");
                t.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255));
            }
            for (VBox v :
                    vBoxes) {
                v.setAlignment(Pos.CENTER);
                v.setPadding(new Insets(0, 15, 0, 10));
            }

            StackPane stackPane = new StackPane();
            stackPane.getChildren().add(imageView1);
            VBox vBox1 = new VBox();
            //vBox1.setPadding(new Insets(0, 0, 0, 0));
            //状态栏
            StackPane statuPane = getStatusBarStackPane(themedirindex, statuDir, false, isDrak);
            //时钟栏
            HBox hBox1 = new HBox();
            hBox1.setPadding(new Insets(30, 0, 0, 30));
            StackPane vb = getTimePane(maindir);
            hBox1.getChildren().add(vb);

            //头像栏

            StackPane music = getMusicPane(maindir);
            HBox hBox = new HBox(music);
            hBox.setPadding(new Insets(120, 0, 0, 46));

            //菜单
            GridPane gridPane1 = new GridPane();
            gridPane1.setPadding(new Insets(400, 0, 0, 50));
            for (int i = 0; i < 8; i++) {
                gridPane1.add(vBoxes.get(i), i % 4, i / 4);
            }
            //翻页
            ImageView imageView22 = new ImageView(new Image(new FileInputStream(maindir[22])));
            HBox hBoxch = new HBox(imageView22);
            imageView22.setFitWidth(80);
            imageView22.setFitHeight(80);
            hBoxch.setPadding(new Insets(0, 0, 0, 170));
            gridPane1.add(hBoxch, 0, 2, 3, 1);
            for (int i = 0; i < 4; i++) {
                gridPane1.add(vBoxes.get(i + 8), i % 4, 3);
            }

            vBox1.getChildren().addAll(statuPane, gridPane1);


            stackPane.getChildren().addAll(hBox1, hBox, vBox1);

            vBox.getChildren().add(stackPane);

            vBox.setPadding(new Insets(20, 20, 20, 50));


        } catch (Exception e) {
            e.printStackTrace();
        }
        return vBox;
    }

    public VBox getfourView(String[] maindir, InputStream[] statuDir, boolean isDrak) {
        VBox vBox = new VBox();
        try {
            ImageView imageView = new ImageView(new Image(new FileInputStream(maindir[4])));
            imageView.setFitWidth(480);
            imageView.setFitHeight(834);

            //标题栏
            ImageView imageView0 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[0], 150, 150))));
            imageView0.setFitWidth(50);
            imageView0.setFitHeight(50);
            //菜单栏
            File file = DisposeNinePatch.creatLargePic(maindir[1], 300, 100);
            ImageView imageView1 = new ImageView(new Image(new FileInputStream(file)));
            imageView1.setFitWidth(210);
            imageView1.setFitHeight(30);
            ImageView imageView11 = new ImageView(new Image(new FileInputStream(file)));
            imageView11.setFitWidth(210);
            imageView11.setFitHeight(30);
            //信息左
            ImageView imageView2 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[2], 800, 400))));
            imageView2.setFitWidth(350);
            imageView2.setFitHeight(160);
            //信息右
            ImageView imageView3 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[3], 800, 400))));
            imageView3.setFitWidth(350);
            imageView3.setFitHeight(160);

            //呼叫背景
            ImageView imageView4 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[8], 800, 400))));
            imageView4.setFitWidth(240);
            imageView4.setFitHeight(45);
            ImageView imageView55 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[8], 800, 400))));
            imageView55.setFitWidth(240);
            imageView55.setFitHeight(45);
            ImageView imageView66 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[8], 800, 400))));
            imageView66.setFitWidth(480);
            imageView66.setFitHeight(60);

            HBox hBox44 = new HBox(imageView4);
            HBox hBox55 = new HBox(imageView55);
            HBox hBox66 = new HBox(imageView66);

            StackPane mainStackPane = new StackPane();
            mainStackPane.getChildren().add(imageView);

            VBox vBox1 = new VBox();
            vBox1.setPadding(new Insets(0, 0, 0, 0));
            String themedir = maindir[0].substring(0, maindir[0].lastIndexOf("/"));
            String themedirindex = themedir.substring(0, themedir.lastIndexOf("/"));
            vBox1.getChildren().add(getStatusBarStackPane(themedirindex, statuDir, true, isDrak));

            //标题栏
            Color color = ReadColor.getColor(new Image("file:" + maindir[0]), 55, 70);
            boolean threePic = color.toString().equals(ResName.color[2]);
            HBox hBox = new HBox();
            Text text1 = new Text("糖糖");
            if (isDrak) {
                text1.setText("艾米");
            }
            if (threePic) {
                text1.setText("Fenda");
            }
            text1.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            String colorv1[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "windowTitleColor");
            text1.setFill(Color.web(colorv1[0], (double) Integer.parseInt(colorv1[1], 16)/255));
            Text text2 = new Text("编辑");
            text2.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            HBox hBoxTitle = new HBox(text1, text2);
            String colorv2[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "color_personal_center_light");
            text2.setFill(Color.web(colorv2[0], (double) Integer.parseInt(colorv2[1], 16)/255));
            hBoxTitle.setPadding(new Insets(15, 0, 10, 60));
            hBoxTitle.setSpacing(150);

            HBox hh = new HBox(imageView0);
            hh.setPadding(new Insets(0,0,0,0));
            hBox.getChildren().addAll(hh, hBoxTitle);
            hBox.setSpacing(100);
            hBox.setPadding(new Insets(0, 0, 0, 50));
            //菜单栏
            String ss = maindir[0].substring(0, maindir[0].lastIndexOf("/"));
            Color colormenu = ReadColor.getColor(new Image("file:" + ss + "/vigour_btn_title_tab_left_center_contact_pressed.9.png"), 30, 60);
            //secHBox.setStyle("-fx-background-color: #" + color1.toString().substring(2,color1.toString().length()));

            HBox hBox1 = new HBox();
            hBox1.setPadding(new Insets(0, 30, 0, 25));
            Text text3 = new Text("呼叫");
            text3.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 18));
            String colorv3[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "text_normal_color");
            text3.setFill(Color.web(colorv3[0], (double) Integer.parseInt(colorv3[1], 16)/255));
            Text text4 = new Text("查看联系人");
            text4.setFill(Color.web(colorv3[0], (double) Integer.parseInt(colorv3[1], 16)/255));
            text4.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 18));
            StackPane stackPane = new StackPane();
            HBox leftm = new HBox(imageView1);
            leftm.setPadding(new Insets(8, 0, 8, 20));
            //leftm.setStyle("-fx-background-color: white");
            HBox hBoxT3 = new HBox(text3);
            hBoxT3.setPadding(new Insets(13,0,0,110));
            stackPane.getChildren().addAll(hBox44,leftm, hBoxT3);
            StackPane stackPane1 = new StackPane();
            HBox rightm = new HBox(imageView11);
            rightm.setPadding(new Insets(8, 20, 8, 20));
            //rightm.setStyle("-fx-background-color: white");
            stackPane1.getChildren().addAll(hBox55,rightm, text4);
            hBox1.getChildren().addAll(stackPane, stackPane1);
            hBox1.setPadding(new Insets(0,0,0,35));
            //hBox1

            String s1[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "text_normal_color");
            if (isDrak) {
                ObservableList list = hBox1.getChildren();
                hBox1.getChildren().removeAll(list);
//                Separator separator = new Separator();
//                separator.setOrientation(Orientation.VERTICAL);
//                separator.setPrefSize(1, 5);
                Line line = new Line(0, 0, 0, 20);
                line.setStroke(Color.GRAY);
                VBox v = new VBox(line);
                v.setPadding(new Insets(10,0,0,20));

                text3.setFill(Color.web(s1[0], (double) Integer.parseInt(s1[1], 16)/255));
                text4.setFill(Color.web(s1[0], (double) Integer.parseInt(s1[1], 16)/255));
                text3.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
                text4.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
                VBox v3 = new VBox(text3);
                VBox v4 = new VBox(text4);

                v3.setPadding(new Insets(10, 90, 0, 90));
                v4.setPadding(new Insets(10, 0, 0, 70));
                HBox hx = new HBox(v3, v, v4);
                hx.setPadding(new Insets(10,0,0,0));
                StackPane sp1 = new StackPane(hBox66,hx);
                hBox1.getChildren().add(sp1);
                hBox1.setMaxWidth(480);

//                Color color1 = ReadColor.getColor(new Image("file:" + maindir[2]), 20, 30);
//                text3.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
//                v3.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
//                v4.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
            }
            if (threePic) {
                //hBox1.setPadding(new Insets(0, 30, 0, 25));
                Text text33 = new Text("呼叫");
                text33.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
                text33.setFill(Color.web(s1[0], (double) Integer.parseInt(s1[1], 16)/255));
                Text text44 = new Text("查看联系人");
                text44.setFill(Color.web(s1[0], (double) Integer.parseInt(s1[1], 16)/255));
                text44.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
                HBox hBox11 = new HBox(text33);
                hBox11.setPadding(new Insets(10, 0, 0, 90));
                HBox hBox22 = new HBox(text44);
                hBox22.setPadding(new Insets(10, 0, 0, 180));
                HBox hBox12 = new HBox(hBox11, hBox22);
                HBox hBox33 = new HBox(stackPane, stackPane1);
                StackPane stackPane2 = new StackPane(hBox33, hBox12);
                //stackPane2.setPadding(new Insets(0,0,0,20));
                ObservableList list = hBox1.getChildren();
                hBox1.getChildren().removeAll(list);

                hBox1.getChildren().addAll(stackPane2);

                //String s = statuDir[8].substring(0, statuDir[8].lastIndexOf("/"));
                //System.out.println("*******************" + new File(maindir[0]).getParent());
                String s = new File(maindir[0]).getParent().substring(0,new File(maindir[0]).getParent().lastIndexOf("\\"));
                Color color1 = ReadColor.getColor(new Image("file:" + s + "/com.android.systemui/vivo_statusbar_title_bg.9.png"), 20, 20);
                leftm.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
                rightm.setStyle("-fx-background-color: #" + color1.toString().substring(2, color1.toString().length()));
            }


            //信息
            StackPane leftStackPane = new StackPane();
            Text text5 = new Text("你好，好喜欢你们的设计呢~期待每周都新主题出来，希望会有很多主题类型呢~加油~");
            text5.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            String colorv4[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "from_context_font_color");
            text5.setFill(Color.web(colorv4[0], (double) Integer.parseInt(colorv4[1], 16)/255));
            TextFlow textFlow1 = new TextFlow(text5);
            textFlow1.setMaxWidth(280);
            textFlow1.setLineSpacing(5);

            Text text8 = new Text("10:15");
            text8.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 15));
            String colorv5[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "from_time_font_color");
            text8.setFill(Color.web(colorv5[0], (double) Integer.parseInt(colorv5[1], 16)/255));

            Text text9 = new Text("1月21日");
            text9.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 15));
            String colorv6[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "date_font_color");
            text9.setFill(Color.web(colorv6[0], (double) Integer.parseInt(colorv6[1], 16)/255));
            HBox hBox9 = new HBox(text9);
            hBox9.setPadding(new Insets(20, 0, 40, 160));

            HBox hBox8 = new HBox(text8);
            hBox8.setPadding(new Insets(15, 0, 0, 250));
            VBox vBox2 = new VBox(hBox9, textFlow1, hBox8);
            vBox2.setPadding(new Insets(0, 0, 0, 50));

            HBox hBox2 = new HBox(imageView2);
            hBox2.setPadding(new Insets(50, 0, 0, 20));
            leftStackPane.getChildren().addAll(hBox2, vBox2);
            leftStackPane.setPadding(new Insets(0, 0, 0, 40));

            StackPane rightStackPane = new StackPane();
            Text text6 = new Text("您好，非常感谢您的喜欢~我们会继续努力呢^^");
            text6.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));

            String colorv7[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "context_font_color");
            text6.setFill(Color.web(colorv7[0], (double) Integer.parseInt(colorv7[1], 16)/255));

            TextFlow textFlow2 = new TextFlow(text6);
            textFlow2.setMaxWidth(280);
            textFlow2.setLineSpacing(5);
            Text text7 = new Text("05:30");
            String colorv8[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "time_font_color");
            text7.setFill(Color.web(colorv8[0], (double) Integer.parseInt(colorv8[1], 16)/255));
            text7.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 15));

            Text text10 = new Text("1月21日");
            text10.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 15));
            String colorv9[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "date_font_color");
            text10.setFill(Color.web(colorv9[0], (double) Integer.parseInt(colorv9[1], 16)/255));
            HBox hBox10 = new HBox(text10);
            hBox10.setPadding(new Insets(15, 0, 60, 80));

            HBox hBox7 = new HBox(text7);
            hBox7.setPadding(new Insets(30, 0, 0, 240));
            VBox vBox3 = new VBox(hBox10, textFlow2, hBox7);
            vBox3.setPadding(new Insets(0, 0, 0, 170));

            HBox hBox3 = new HBox(imageView3);
            hBox3.setPadding(new Insets(60, 60, 0, 140));
            rightStackPane.getChildren().addAll(hBox3, vBox3);

            //回形针
            ImageView imageView5 = new ImageView(new Image(new FileInputStream(maindir[5])));
            imageView5.setFitWidth(30);
            imageView5.setFitHeight(30);

            //发送框
            File fileindex = DisposeNinePatch.creatLargePic(maindir[6],500,100);
            InputStream is = DisposeNinePatch.zoomPic(fileindex,480,50);

            ImageView imageView6 = new ImageView(new Image(is));
            imageView6.setFitWidth(340);
            imageView6.setFitHeight(40);

            //底边背景
            ImageView imageView7 = new ImageView(new Image(new FileInputStream(DisposeNinePatch.creatLargePic(maindir[7], 1100, 150))));
            imageView7.setFitWidth(480);
            imageView7.setFitHeight(60);

            HBox hBox56 = new HBox(imageView5, imageView6);
            hBox56.setSpacing(10);
            StackPane stackPane56 = new StackPane(hBox56);
            Text textt = new Text("输入内容");
            textt.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            textt.setFill(Color.web("#7c7c7c"));
            Text textsent = new Text("发送");
            textsent.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 20));
            String colorv10[] = new MainListenController().getXmlvalue(themedirindex + "/com.android.mms\\theme_values.xml", "compose_send_text_color");
            textsent.setFill(Color.web(colorv10[0], (double) Integer.parseInt(colorv10[1], 16)/255));
            HBox hBox57 = new HBox(textt, textsent);
            hBox57.setPadding(new Insets(8, 0, 0, 50));
            hBox57.setSpacing(270);
            stackPane56.getChildren().add(hBox57);
            stackPane56.setPadding(new Insets(788, 0, 0, 50));

            HBox pic = new HBox(imageView7);
            pic.setPadding(new Insets(778,0,0,35));
            StackPane sp = new StackPane(pic,stackPane56);

            vBox1.getChildren().addAll(hBox, hBox1, leftStackPane, rightStackPane);
            mainStackPane.getChildren().addAll(vBox1, sp);

            vBox.getChildren().add(mainStackPane);

            vBox.setPadding(new Insets(20, 20, 20, 50));


        } catch (FileNotFoundException e) {

        }

        return vBox;
    }

    private GridPane getTextGrid(String[] strings, Color color) {

        GridPane gridPane = new GridPane();
        //gridPane.setPrefSize(480, 400);
        //gridPane.setAlignment(Pos.CENTER_LEFT);
        Text text = new Text(strings[0]);
        text.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 24));
        Text text1 = new Text(strings[1]);
        text1.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 15));
        Text text2 = new Text(strings[2]);
        text2.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 18));
        HBox hBox = new HBox(text);
        hBox.setAlignment(Pos.BOTTOM_LEFT);
        HBox hBox1 = new HBox(text1);
        hBox1.setAlignment(Pos.BOTTOM_RIGHT);
        hBox1.setPadding(new Insets(0, 20, 0, 0));
        HBox hBox2 = new HBox(text2);
        hBox2.setAlignment(Pos.BOTTOM_LEFT);
        hBox2.setPadding(new Insets(0, 0, 10, 0));
        Line line = new Line(0, 20, 450, 20);
        line.setStroke(color);
//        VBox vBox = new VBox(text2,line);
        hBox2.setPadding(new Insets(0, 0, 5, 0));
//        hBox2.getChildren().add(line);
//        Separator s = new Separator();
//        s.setPrefWidth(400);
//        s.setPrefHeight(1);
//        s.setStyle("-fx-border-color: #" + color.toString().substring(2,color.toString().length()));
        String colorv1[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "text_normal_color");
        String colorv2[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "text_second_normal_color");
        String colorv3[] = new MainListenController().getXmlvalue(themedirindex + "/vivo\\theme_values.xml", "text_normal_color");
        text.setFill(Color.web(colorv1[0],(double) Integer.parseInt(colorv1[1], 16)/255));
        text1.setFill(Color.web(colorv2[0],(double) Integer.parseInt(colorv2[1], 16)/255));
        text2.setFill(Color.web(colorv3[0],(double) Integer.parseInt(colorv3[1], 16)/255));
        gridPane.add(hBox, 0, 0, 1, 1);
        gridPane.add(hBox1, 1, 0, 1, 1);
        gridPane.add(hBox2, 0, 1, 2, 1);
        gridPane.add(line, 0, 2, 2, 1);

        gridPane.setPadding(new Insets(10, 0, 10, 50));

        return gridPane;
    }

    /**
     * 状态栏
     */
    private StackPane getStatusBarStackPane(String basedir, InputStream[] statusDir, boolean background, boolean isDark) {

        StackPane statusBarStackPane = new StackPane();
        try {
            //4g
            //ImageView imageView = new ImageView(new Image(new FileInputStream(statusDir[0])));
            ImageView imageView = new ImageView(new Image(statusDir[0]));
            imageView.setFitWidth(15);
            imageView.setFitHeight(15);
            //时间
//            ImageView imageView1 = new ImageView(new Image(new FileInputStream(statusDir[1])));
            ImageView imageView1 = new ImageView(new Image(statusDir[1]));
            imageView1.setFitWidth(45);
            imageView1.setFitHeight(14);
            //信号
//            ImageView imageView2 = new ImageView(new Image(new FileInputStream(statusDir[2])));
            ImageView imageView2 = new ImageView(new Image(statusDir[2]));
            imageView2.setFitWidth(15);
            imageView2.setFitHeight(15);
            //wifi
//            ImageView imageView3 = new ImageView(new Image(new FileInputStream(statusDir[3])));
            ImageView imageView3 = new ImageView(new Image(statusDir[3]));
            imageView3.setFitWidth(18);
            imageView3.setFitHeight(12);
            //电池
//            ImageView imageView4 = new ImageView(new Image(new FileInputStream(statusDir[4])));
            ImageView imageView4 = new ImageView(new Image(statusDir[4]));
            imageView4.setFitWidth(27);
            imageView4.setFitHeight(27);

            HBox hBox = new HBox(imageView, imageView2);
            hBox.setPadding(new Insets(10, 0, 0, 15));
            hBox.setSpacing(3);
            HBox hBox1 = new HBox(imageView1);
            hBox1.setPadding(new Insets(8, 0, 0, 175));
            HBox hBox33 = new HBox(imageView3);
            hBox33.setPadding(new Insets(8, 0, 0, 0));
            HBox hBox44 = new HBox(imageView4);
            hBox44.setPadding(new Insets(0, 0, 0, 2));
            HBox hBox2 = new HBox(hBox33, hBox44);
            hBox2.setPadding(new Insets(5, 0, 0, 150));
            HBox hBox3 = new HBox(hBox, hBox1, hBox2);

            String colorname = new MainListenController().getXmlvaluename(basedir + "/vivo\\theme_values.xml", "vivo_window_statusbar_bg_color");
            System.out.println("12   " + basedir +"5" +colorname);
            colorname = colorname.substring(3,colorname.length());

            if(background){
                hBox3.setStyle("-fx-background-color: #" + colorname);
            }
            hBox3.setMaxSize(480, 100);
            statusBarStackPane.setPrefSize(480, 30);
            statusBarStackPane.getChildren().addAll(hBox3);
        } catch (Exception e) {
            e.printStackTrace();
        }


        return statusBarStackPane;
    }

    private StackPane getMusicPane(String music[]) throws Exception {
        String themedir = music[0].substring(0, music[0].lastIndexOf("/"));
        themedirindex = themedir.substring(0, themedir.lastIndexOf("/"));
        Color color1 = ReadColor.getColor(new Image("file:" + music[20]), 80, 80);
        Text text1 = new Text("歌曲名");
        text1.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 17));
        String colorv1[] = new MainListenController().getXmlvalue(themedirindex + "/com.vivo.dream.music\\theme_values.xml", "dream_music_song_name");
        text1.setFill(Color.web(colorv1[0],(double) Integer.parseInt(colorv1[1], 16)/255));
        Text text2 = new Text("歌手名");
        text2.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 17));
        String colorv2[] = new MainListenController().getXmlvalue(themedirindex + "/com.vivo.dream.music\\theme_values.xml", "dream_music_artist");
        text2.setFill(Color.web(colorv2[0],(double) Integer.parseInt(colorv2[1], 16)/255));
        HBox hBox = new HBox(text1, text2);
        hBox.setPadding(new Insets(10, 0, 0, 160));
        hBox.setSpacing(100);
        Circle circle = new Circle(50, 50, 45);
        //头像
        ImageView imageView = new ImageView(new Image(new FileInputStream(music[16])));
        imageView.setClip(circle);
        imageView.setFitWidth(100);
        imageView.setFitHeight(100);
        HBox hBoxHead = new HBox(imageView);
        hBoxHead.setPadding(new Insets(5, 0, 0, 5));

        //白圈
        ImageView imageView1 = new ImageView(new Image("file:" + music[17]));
        imageView1.setFitHeight(110);
        imageView1.setFitWidth(110);
        HBox hBoxcircle = new HBox(imageView1);
        StackPane stackPane = new StackPane(hBoxHead, hBoxcircle);
        stackPane.setPadding(new Insets(0, 0, 0, 40));
        stackPane.setPrefSize(120, 120);
        //HBox hBox2 = new HBox(stackPane);
        //外框
        ImageView imageView2 = new ImageView(new Image("file:" + music[18]));
        imageView2.setFitWidth(445);
        imageView2.setFitHeight(120);
        VBox vBox = new VBox(imageView2);
        //上一首
        ImageView imageView3 = new ImageView(new Image("file:" + music[19]));
        imageView3.setFitWidth(60);
        imageView3.setFitHeight(60);
        //bof
        ImageView imageView4 = new ImageView(new Image("file:" + music[20]));
        imageView4.setFitWidth(60);
        imageView4.setFitHeight(60);
        //下一首
        ImageView imageView5 = new ImageView(new Image("file:" + music[21]));
        imageView5.setFitWidth(60);
        imageView5.setFitHeight(60);
        HBox hBox1 = new HBox(imageView3, imageView4, imageView5);
        hBox1.setPadding(new Insets(50, 0, 0, 200));
        hBox1.setSpacing(10);

        StackPane stackPane1 = new StackPane(hBox, vBox, stackPane, hBox1);
        //StackPane stackPane1 = new StackPane(hBox,vBox,hBox1);
        stackPane1.setPadding(new Insets(20, 0, 0, 0));
        //System.out.println(stackPane1.heightProperty().getValue());
        //StackPane stackPane1 = new StackPane(hBox2);
        return stackPane1;
    }

    private StackPane getTimePane(String time[]){
        StackPane mainHbox = null;
        try {
            //透明框
            ImageView imageView = new ImageView(new Image(new FileInputStream(time[23])));
            imageView.setFitWidth(445);
            imageView.setFitHeight(35);
            //0
            ImageView imageView1 = new ImageView(new Image(new FileInputStream(time[24])));
            imageView1.setFitWidth(40);
            imageView1.setFitHeight(65);
            //2
            ImageView imageView2 = new ImageView(new Image(new FileInputStream(time[25])));
            imageView2.setFitWidth(40);
            imageView2.setFitHeight(65);

            //5
            ImageView imageView3 = new ImageView(new Image(new FileInputStream(time[26])));
            imageView3.setFitWidth(40);
            imageView3.setFitHeight(65);
            //：
            ImageView imageView4 = new ImageView(new Image(new FileInputStream(time[27])));
            imageView4.setFitWidth(20);
            imageView4.setFitHeight(65);
            //编辑
            ImageView imageView5 = new ImageView(new Image(new FileInputStream(time[28])));
            imageView5.setFitWidth(40);
            imageView5.setFitHeight(32);
            //0
            ImageView imageView6 = new ImageView(new Image(new FileInputStream(time[24])));
            imageView6.setFitWidth(40);
            imageView6.setFitHeight(65);

//            t.setFont(Font.loadFont("file:src/com/Droid Sans Fallback.ttf", 16));
//            String s[] = new MainListenController().getXmlvalue(themedirindex + "/com.bbk.launcher2\\theme_values.xml", "icon_title_color");
//            t.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255)); com.vivo.dream.clock\theme_values.xml

            String s[] = new MainListenController().getXmlvalue(themedirindex + "/com.vivo.dream.clock\\theme_values.xml", "dream_clock_date");

            //05:20
            HBox hBox = new HBox(imageView1,imageView3,imageView4,imageView2,imageView6);

            Text text1 = new Text("抒写心情");
            text1.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 38));
            text1.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255));
            HBox hBoxt1 = new HBox(text1);
            hBoxt1.setPadding(new Insets(10,0,0,60));

            HBox hBox11 = new HBox(hBox,hBoxt1);
            hBox11.setPadding(new Insets(20,0,0,20));

            Text text2 = new Text("2018年2月23日");
            text2.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 14));
            text2.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255));
            HBox hBoxt2 = new HBox(text2);
            hBoxt2.setPadding(new Insets(11,0,0,20));
            Text text3 = new Text("星期五");
            text3.setFont(Font.loadFont(this.getClass().getResourceAsStream("Droid Sans Fallback.ttf"), 14));
            text3.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255));
            HBox hBoxt3 = new HBox(text3);
            hBoxt3.setPadding(new Insets(11,0,0,80));
            //Text text4 = new Text("我的姿态，无可替代");
            //text4.setFont(Font.loadFont("file:src/com/Droid Sans Fallback.ttf", 15));
            //text4.setFill(Color.web(s[0], (double) Integer.parseInt(s[1], 16)/255));
            //HBox hBoxt4 = new HBox(text4);
            HBox hBoxt5 = new HBox(imageView5);
            hBoxt5.setPadding(new Insets(1,0,0,160));

            HBox hBox1 = new HBox(hBoxt2,hBoxt3,hBoxt5);

            StackPane stackPane = new StackPane(imageView,hBox1);
            VBox vBox = new VBox(stackPane);
            vBox.setPadding(new Insets(75,0,0,15));




            mainHbox = new StackPane(hBox11,vBox);
            //mainHbox.setPadding(new Insets(20,0,0,20));


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }



        return mainHbox;
    }
}
